package mybbs;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

public class LatestopicBean {
	 private PostInfo topic;
	 private int listlength=10;
public int getListlength() {
		return listlength;
	}
	public void setListlength(int listlength) {
		this.listlength = listlength;
	}
public List getLatestlist() throws Exception {
	DBConn conn = new DBConn();
	List list = new ArrayList();	
	String sql="SELECT id FROM posts WHERE istopic>0 AND isdel=0 ORDER BY post_time DESC";
	try {
		ResultSet rs = conn.query(sql);
		while (rs.next()) 
		{  if(rs.getRow()>listlength)
			break;
			topic=new PostInfo();
			topic.setPostid(rs.getInt("id"));
			list.add(topic);
		}
		conn.DBclose();
		}
		catch (Exception e) {
			e.printStackTrace();
		}
		return list;
}
}
